package com.pic.mgt.monitor.check;

import com.pic.mgt.monitor.WrongUnitFormatException;

public class BizFilenameLenCheck implements FormatCheck {
	private String businessConfirmationSuffix;
	private int targetFilenameLen;
	
	private int businessConfirmationSuffixLen;
	
	@Override
	public void check(String confirmationFilename)
						throws WrongUnitFormatException {
		int confirmationFilenameLen = confirmationFilename.length();
		
		int suffixLen = confirmationFilenameLen - targetFilenameLen;
		
		if (suffixLen != businessConfirmationSuffixLen) {
			throw new WrongUnitFormatException(
					"Wrong confirmation filename length : '" + confirmationFilename + "'");
		}
	}
	
	// --- getter and setter ---

	public void setBusinessConfirmationSuffix(String businessConfirmationSuffix) {
		this.businessConfirmationSuffix = businessConfirmationSuffix;
		this.businessConfirmationSuffixLen = businessConfirmationSuffix.length();
	}

	public void setTargetFilenameLen(int targetFilenameLen) {
		this.targetFilenameLen = targetFilenameLen;
	}	
}
